package common.db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBClose {
	
	public static void close(Statement stmt, Connection conn){
		try {
			if(null != stmt)
				stmt.close();
			if(null != conn)
				conn.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}	
	}
	
	public static void close(ResultSet rs, Statement stmt, Connection conn){
		try {
			if(null != rs)
				rs.close();
			
			if(null != stmt)
				stmt.close();
			if(null != conn)
				conn.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}	
	}
	
	public static void close(PreparedStatement pstmt, Connection conn){
		try {
			if(null != pstmt)
				pstmt.close();
			if(null != conn)
				conn.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}	
	}
	
	public static void close(ResultSet rs, PreparedStatement pstmt, Connection conn){
		try {
			if(null != rs)
				rs.close();
			
			if(null != pstmt)
				pstmt.close();
			if(null != conn)
				conn.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}	
	}
}
